const App = getApp();
const navigationBarHeight = (getApp().diygwstatusBarHeight + 44) + 'px'
Page({
    data: {
        
        buttons3: [{
            type: 'submit',
            url: App.renderUrl('empty', 'index'),
            title: ``
        }]
    },

   //弹出提示信息
    showModal(message) {
        App.WxService.showModal({
            title: '友情提示',
            content: message,
            showCancel: !1,
        });
    },
    onShareAppMessage: function() {},

    //页面加载
    onLoad(option) {
        if (option) {
            this.setData({
                globalOption: option
            })
        }
    },

   //页面显示
    onShow() {
        this.getForm1();
    },

    //设置输入验证
    getForm1() {
        this.WxValidate = App.WxValidate({
            
        })
    },

    //注册
    formSubmit1: function(e) {
        if (!this.WxValidate.checkForm(e)) {  //输入验证不通过时，弹出相应的提示信息，并返回
            const error = this.WxValidate.errorList[0]
            var msg = `${error.msg}`;
            this.showModal(msg);
            return false
        } else {
            var data = e.detail.value;

            data = App.Tools.extend(data, {
                id: this.data.globalOption.id,
            });

            App.HttpService.saveData(data, "/reimburse_Add").then(data => { //执行服务器端Servlet，并根据返回值，弹出相应的提示
                App.WxService.showToast({
                    title: "提交成功，请等待管理员的审核!",
                    icon: 'none',
                    duration: 1500,
                });
                setTimeout(function() {
                    wx.navigateBack(); //返回到登录页
                }, 1500)
            });
        }
    },
    formReset1: function() {
        console.log('form发生了reset事件')
    },
    

})
